


**


project , uses("constituency_elections.dta")


	**Effect on Spending by Category
	use "constituency_elections.dta", clear //open data
	gen est = .
	gen upper95 = .
	gen lower95 = .
	gen upper90 = .
	gen lower90 = .
	gen lead = .
	gen upper95_lead = .
	gen lower95_lead = .
	gen upper90_lead = .
	gen lower90_lead = .
	gen category = ""
	rename spending_managers_adj spending_agents_adj
	local i = 0 
	foreach v in total ads agents staff meetings facilities  misc personal {
		reghdfe  spending_`v'_adj  F0.spending_limit_predicted_adj F1.spending_limit_predicted_adj   countyXelectors , a(  const_id date  i.date#c.electors     ) cluster(const_id) keepsingletons
		local i = `i' + 1
		replace est = _b[F0.spending_limit_predicted_adj] if _n==`i'
		replace upper95 = _b[F0.spending_limit_predicted_adj] + 1.96*_se[F0.spending_limit_predicted_adj] if _n==`i'
		replace lower95 = _b[F0.spending_limit_predicted_adj] - 1.96*_se[F0.spending_limit_predicted_adj] if _n==`i'
		replace upper90 = _b[F0.spending_limit_predicted_adj] + 1.64*_se[F0.spending_limit_predicted_adj] if _n==`i'
		replace lower90 = _b[F0.spending_limit_predicted_adj] - 1.64*_se[F0.spending_limit_predicted_adj] if _n==`i'
		
		
		replace lead = _b[F1.spending_limit_predicted_adj] if _n==`i'
		replace upper95_lead = _b[F1.spending_limit_predicted_adj] + 1.96*_se[F1.spending_limit_predicted_adj] if _n==`i'
		replace lower95_lead = _b[F1.spending_limit_predicted_adj] - 1.96*_se[F1.spending_limit_predicted_adj] if _n==`i'			
		replace upper90_lead = _b[F1.spending_limit_predicted_adj] + 1.64*_se[F1.spending_limit_predicted_adj] if _n==`i'
		replace lower90_lead = _b[F1.spending_limit_predicted_adj] - 1.64*_se[F1.spending_limit_predicted_adj] if _n==`i'	
		
		replace category = proper("`v'") + ", t" if _n==`i'
	}
	keep if est!=.
	keep est upper* lower* lead category
	sort est category
	gen rank = _n
	gen rank1 = _n-.1
	labmask rank, values(category)
	
	twoway  (rspike upper95 lower95 rank, horizontal lcolor(black) lwidth(vthin)) ///
			(rspike upper90 lower90 rank, horizontal lcolor(black) lwidth(medthick) ) ///
			(dot est rank,horizontal ndots(1) mcolor(black) msymbol(s) msize(medlarge) mfcolor(white))  ///
			(rspike upper95_lead lower95_lead rank1, horizontal lcolor(gs12) lwidth(vthin)) ///
			(rspike upper90_lead lower90_lead rank1, horizontal lcolor(gs12) lwidth(medthick)) ///
			(dot lead rank1,horizontal ndots(1) mcolor(gs12) msymbol(o) msize(medlarge) mfcolor(white))  , ///		
			subtitle(, bcolor(white)) xline(0, lcolor(black)) graphregion(color(white))  ylabel(1 (1) 8,valuelabel angle(horizontal))  ///
			ytitle("")    xtitle("Effect of Spending Limit (£10,000)" "on Spending by Category") legend(col(1) pos(5) ring(0) order(3 "Spending Limit, t" 6 "Spending Limit, t+1"))	scale(1.2)
	graph export ./figures/spending_types.pdf, replace				
	project , creates("figures/spending_types.pdf")	

	
